<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>抽奖配置管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
            /* $("#name").val('${lotteryConfig.user.name }');  */
			$("#percent").focus();
			$('#validDays').val('${lotteryConfig.validDays}');
			
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		
		
		function showMsg(){
			alert($("input[type='radio'][name='startup'][checked='checked']").val());
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		
		<shiro:hasPermission name="sys:user:edit"><li>	<a href="${ctx}/wechat/lotteryConfig/">抽奖配置列表</a></li></shiro:hasPermission>
		<li class="active"><a href="${ctx}/wechat/lotteryConfig/form?id=${lotteryConfig.id}">抽奖配置<shiro:hasPermission name="wechat:lotteryConfig:edit">${not empty lotteryConfig.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="wechat:lotteryConfig:edit">查看</shiro:lacksPermission></a></li>
		<shiro:hasPermission name="wechat:lottery:view"><li><a href="${ctx}/wechat/lottery/">奖品列表</a></li></shiro:hasPermission>
		<shiro:hasPermission name="wechat:lottery:edit"><li><a href="${ctx}/wechat/lottery/form">添加奖品</a></li></shiro:hasPermission>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="lotteryConfig" action="${ctx}/wechat/lotteryConfig/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<form:hidden path="user.id"/>
		
		<tags:message content="${message}"/>
		<%-- <div class="control-group">
			<label class="control-label">名称:</label>
			<div class="controls">
				<form:input path="name" htmlEscape="false" maxlength="50" readonly="true" />
			</div>
		</div> --%>
		<div class="control-group">
			<label class="control-label">中奖机率:</label>
			<div class="controls">
				<form:input path="percent" htmlEscape="false" maxlength="11" class="required"/>%   <span>全局中奖机率</span>
			</div>
		</div>
		
		
		<div class="control-group">
			<label class="control-label">兑换奖品有效天数:</label>
			<div class="controls">
				<select name="validDays" id="validDays">
					<% for(int i=1;i<31;i++) {%>
					<option value="<%=i%>" ><%=i %>天</option>
					<%} %>
				</select>
			</div>
		</div>

		<div class="control-group">
			<label class="control-label">是否开启:</label>
			<div class="controls">
				<form:radiobutton path="startup" value="true"/>是 
				<form:radiobutton path="startup" value="false"/>否
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">是否扣除积分:</label>
			<div class="controls">
				<input type="radio" name="cost" value="true" <c:if test="${lotteryConfig.cost eq true }">  checked="checked" </c:if> /> 是   <input type="radio" name="cost" value="false" <c:if test="${lotteryConfig.cost eq false }">  checked="checked" </c:if> /> 否
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">是否允许重复:</label>
			<div class="controls">
				<input type="radio" name="repeats" value="true" <c:if test="${lotteryConfig.repeats eq true }">  checked="checked" </c:if> /> 是   <input type="radio" name="repeats" value="false" <c:if test="${lotteryConfig.repeats eq false }">  checked="checked" </c:if> /> 否
			</div>
		</div>
		
		
		<div class="control-group">
			<label class="control-label">允许每个抽奖次数:</label>
			<div class="controls">
				<form:input path="repeatCount" htmlEscape="false"   class="number"/>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">扣除积分:</label>
			<div class="controls">
				<input name="pScore" class="required number" type="text" htmlEscape="false" value="<fmt:formatNumber value='${lotteryConfig.costScore/1000}' pattern='###.###'  minFractionDigits='3'/>">
				<label style="color:grey"><span class="alert">（元）精确到小数点后三位</span></label>
				<!-- <input name="costScore" class="number"/>
				<label style="color:grey"><span class="alert">积分以“<span style="color:red;">厘</span>”为单位</span></label> -->
			</div>
		</div>
		
		
		
		<div class="control-group">
			<label class="control-label">抽奖队列是否自动清除:</label>
			<div class="controls">
				<input type="radio" name="cleanQueue" value="true" <c:if test="${lotteryConfig.cleanQueue eq true }">  checked="checked" </c:if> /> 是   <input type="radio" name="cleanQueue" value="false" <c:if test="${lotteryConfig.cleanQueue eq false }">  checked="checked" </c:if> /> 否
			</div>
		</div>
		
		
		<div class="control-group">
			<label class="control-label">参与抽奖后加关键词:</label>
			<div class="controls">
				现场抽奖<form:input path="queueKeywords" htmlEscape="false"  /> <span class="alert">默认关键词前会自动添加'现场抽奖'，如此处设置为'1'则用户需要回复'现场抽奖1'</span>
			</div>
		</div>
		
		
		<div class="control-group">
			<label class="control-label">备注:</label>
			<div class="controls">
				<form:input path="remarks" htmlEscape="false" maxlength="50" />
			</div> 
		</div>
		
		
		<div class="form-actions">
			<shiro:hasPermission name="wechat:lotteryConfig:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>
